package com.LachesismStorm.lachesism.member.service.impl;

import com.LachesismStorm.lachesism.core.common.response.ResponsePage;
import com.LachesismStorm.lachesism.member.mapper.LachesismMapper;
import com.LachesismStorm.lachesism.member.service.LachesismService;
import com.LachesismStorm.lachesism.member.vo.OssFile;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lachesism
 * @Date 2025-02-14 03:01
 **/
@Service
public class LachesismServiceImpl implements LachesismService {

    @Resource
    private LachesismMapper lachesismMapper;

    @Override
    public List<String> getRandomUrl() {
        return lachesismMapper.getRandomUrl();
    }

    @Override
    public ResponsePage<OssFile> getOssFileList(OssFile file) {
        PageHelper.startPage(file.getPageNum(), 30);
        List<OssFile> ossFiles = lachesismMapper.getOssFileList(file);
        return ResponsePage.restPage(new PageInfo<>(ossFiles));
    }

    @Override
    public String getDownLoadUrl(Integer id) {
        return lachesismMapper.getOssFileById(id);
    }

    @Override
    public void uploadOssFile(OssFile fileInfo) {
        lachesismMapper.addFileInfo(fileInfo);
    }
}
